tomact
==============================================
http://www.cnblogs.com/caoxiaojian/p/5073608.html

yum -y install jdk-8u25-linux-x64.rpm
which java
/usr/bin/java


tar -axf  apache-tomcat-8.5.4.tar.gz -C  /usr/local/
ln -sv /usr/local/apache-tomcat-8.5.4/  /usr/local/tomcat


 vim /etc/profile.d/java.sh 
export JAVA_HOME=/usr/java/latest
export PATH=$PATH:$JAVA_HOME/bin


vim /etc/profile.d/tomcat.sh  
export CATALINA_HOME=/usr/local/tomcat
export PATH=$PATH:$CATALINA_HOME/bin


[root@localhost java]# . /etc/profile.d/java.sh 
[root@localhost java]# . /etc/profile.d/tomcat.sh 
[root@localhost java]# catalina.sh version 
Using CATALINA_BASE:   /usr/local/tomcat
Using CATALINA_HOME:   /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME:        /usr/java/latest
Using CLASSPATH:       /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Server version: Apache Tomcat/8.5.4
Server built:   Jul 6 2016 08:43:30 UTC
Server number:  8.5.4.0
OS Name:        Linux
OS Version:     3.10.0-229.el7.x86_64
Architecture:   amd64
JVM Version:    1.8.0_25-b17
JVM Vendor:     Oracle Corporation


启动：
/usr/local/tomcat/bin/startup.sh
停止：
/usr/local/tomcat/bin/shutdown.sh

测试：
catalina.sh stop
catalina.sh start

 conf/tomcat-users.xml

<role rolename="manager-gui" />
<role rolename="admin-gui" />
<user username="tomcat" password="tomcat" roles="manager-gui,admin-gui" />



vim conf/server.xml 

<Host name="192.168.31.72"  appBase="/usr/local/tomcat/webapps"
    unpackWARs="true" autoDeploy="true">
<Context path="/cmcmas" docBase="cmcmas" reloadable="true" />
</Host>


/usr/local/tomcat/webapps/cmcmas
 mkdir {classes,lib,WEB-INF,META-INF}

vim index.jsp
<%@ page language="java" %>
<%@ page import="java.util.*" %>
<html>
<head>
    <title>java</title>
</head>
<body>
    <% out.println("hello world");
    %>  
</body>
</html>

http://192.168.31.72:8080/cmcmas/







http://www.cnblogs.com/xuanzhi201111/p/4425194.html 





https://github.com/CodisLabs/codis

yum -y install go
go get github.com/wandoulabs/codis
cd codis
./bootstrap.sh
make gotest
cd sample
follow instructions in usage.md



==============================================
一：简介
Tomcat 是 Java 的web 程序。

~]# which java
/usr/bin/java
~]# ls -l /usr/bin/java
lrwxrwxrwx 1 root root 22 Jun  6 20:37 /usr/bin/java -> /etc/alternatives/java
~]# ls -l /etc/alternatives/java
lrwxrwxrwx 1 root root 72 Jun  6 20:37 /etc/alternatives/java -> /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.91-2.6.2.3.el7.x86_64/jre/bin/java

sexport JAVA_HOME=/usr/bin/




http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

rpm -ivh jdk-7u79-linux-x64.rpm

[root@node2 default]# cat /etc/profile.d/java.sh
JAVA_HOME=/usr/java/latest
export PATH=$JAVA_HOME/bin:$PATH



yum list all *tomcat*

~]# yum -y install tomcat tomcat-lib tomcat-webapps tomcat-admin-webapps
systemctl start tomcat.service

# tar xf apache-tomcat-VERSION.tar.gz  -C /usr/local
# cd /usr/local
# ln -sv apache-tomcat-VERSION tomcat

[root@node2 tomcat]# cat /etc/profile.d/tomcat.sh
CATALINA_BASE=/usr/local/tomcat
export PATH=$CATALINA_BASE/bin:$PATH


catalina.sh --help
[root@node2 tomcat]# catalina.sh start



catalina.sh start


http://172.18.21.71:8080/myapp




<%@ page language="java" %>
<%@ page import="java.util.*" %>
<html>
<head>
    <title>java</title>
</head>
<body>
    <% out.println("hello world");
    %>  
</body>
</html>


[root@node2 jsp]# pwd
/usr/local/tomcat/work/Catalina/localhost/myapp/org/apache/jsp
[root@node2 jsp]# ll
total 8
-rw-r--r-- 1 root root 3913 Jun  7 17:49 index_jsp.class
-rw-r--r-- 1 root root 3167 Jun  7 17:49 index_jsp.java


 conf/tomcat-users.xml

<role rolename="manager-gui"/>
<user username="tomcat" password="tomcat" roles="manager-gui"/>




[root@node2 webapps]# ls
ROOT
[root@node2 webapps]# cp /usr/local/tomcat/webapps/myapp/index.jsp ./ROOT/
[root@node2 webapps]# ls
ROOT
[root@node2 webapps]# cd ROOT/
[root@node2 ROOT]# mkdir classes
[root@node2 ROOT]# mkdir lib
[root@node2 ROOT]# mkdir {WEB-INF,META-INF}

~]# vi /usr/local/tomcat/conf/tomcat-users.xml

<role rolename="manager-gui" />
<role rolename="admin-gui" />
<user username="tomcat" password="tomcat" roles="manager-gui,admin-gui" />



[root@node2 tomcat]# tree /data/webapps/testapp/
/data/webapps/testapp/
├── classes
├── index.jsp
├── lib
├── META-INF
└── WEB-INF

<Host name="node2.magedu.com"  appBase="/data/webapps"
    unpackWARs="true" autoDeploy="true">
<Context path="/test" docBase="testapp" reloadable="true" />
</Host>

curl http://node2.magedu.com:8080/test/




[root@node2 conf.d]# cat http_tomcat.conf
<virtualHost *:80>
    Servername tc1.magedu.com
    ProxyRequests Off
    ProxyVia On
    ProxyPreserveHost On
    <Proxy *>
        Require all granted
    </Proxy>
    ProxyPass / http://localhost:8080/
    ProxyPassReverse / http://localhost:8080/
    <Location />
        Require all granted
    </Location>
</VirtualHost>




[root@node2 conf.d]# cat ajp.tomcat.conf 
<virtualHost *:80>
    Servername tc1.magedu.com
    ProxyRequests Off
    ProxyVia On
    ProxyPreserveHost On
    #ProxyPreserveHost Off
    <Proxy *>
        Require all granted
    </Proxy>
    ProxyPass / ajp://node2.magedu.com:8009/
    ProxyPassReverse / ajp://node2.magedu.com:8009/
    <Location />
        Require all granted
    </Location>
</VirtualHost>


[mdx@node2 tomcat]$ jps
3336 Jps
3214 Bootstrap

[mdx@node2 tomcat]$ jstat -options
-class
-compiler
-gc
-gccapacity
-gccause
-gcnew
-gcnewcapacity
-gcold
-gcoldcapacity
-gcpermcapacity
-gcutil
-printcompilation


[mdx@node2 tomcat]$ jstat -gc 3214
 S0C    S1C    S0U    S1U      EC       EU        OC         OU       PC     PU    YGC     YGCT    FGC    FGCT     GCT   
3776.0 3776.0  0.0    0.0   30208.0  22253.2   75228.0    45135.5   43968.0 43874.9    103    0.541  10      1.162    1.702

垃圾回收列表：
~]$ jstat -gc 3214 2000


startup脚本：~]# vim /etc/rc.d/init.d/tomcat
#!/bin/sh
# Tomcat init script for Linux.
#
# chkconfig: 2345 96 14
# description: The Apache Tomcat servlet/JSP container.
# JAVA_OPTS='-Xms64m -Xmx128m'
JAVA_HOME=/usr/java/latest
CATALINA_HOME=/usr/local/tomcat
export JAVA_HOME CATALINA_HOME

case $1 in
start)
  exec $CATALINA_HOME/bin/catalina.sh start ;;
stop)
  exec $CATALINA_HOME/bin/catalina.sh stop;;
restart)
  $CATALINA_HOME/bin/catalina.sh stop
  sleep 2
  exec $CATALINA_HOME/bin/catalina.sh start ;;
configtest)
  exec $CATALINA_HOME/bin/catalina.sh configtest ;;
*)
  exec $CATALINA_HOME/bin/catalina.sh * ;;
esac





http://172.18.21.71/myapp/index.jsp




tomcat A，B


proxy_ajp_module
proxy_

















二：安装

1.1：

1.2：


三：配置

~]# yum -y install openjdk openjdk-devel



~]# yum -y install java-1.7.0-openjdk.x86_64 java-1.7.0-openjdk-devel.x86_64











ab -n 10000 -c 10 http://172.18.21.72/
ab -n 10000 -c 10 http://172.18.21.30/







[root@node2 myapp]# ab -n 1000000 -c 10 http://172.18.21.71/
This is ApacheBench, Version 2.3 <$Revision: 1430300 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 172.18.21.72 (be patient)
Completed 10000 requests
Completed 20000 requests
Completed 30000 requests
Completed 40000 requests
Completed 50000 requests
Completed 60000 requests
Completed 70000 requests
Completed 80000 requests
Completed 90000 requests
Completed 100000 requests
Finished 100000 requests


Server Software:        Apache/2.4.6
Server Hostname:        172.18.21.72
Server Port:            80

Document Path:          /
Document Length:        421 bytes

Concurrency Level:      10
Time taken for tests:   75.114 seconds
Complete requests:      100000
Failed requests:        0
Write errors:           0
Total transferred:      68700000 bytes
HTML transferred:       42100000 bytes
Requests per second:    1331.31 [#/sec] (mean)
Time per request:       7.511 [ms] (mean)
Time per request:       0.751 [ms] (mean, across all concurrent requests)
Transfer rate:          893.18 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.1      0       7
Processing:     1    7  71.0      4    4175
Waiting:        0    7  71.0      4    4174
Total:          1    7  71.0      4    4175

Percentage of the requests served within a certain time (ms)
  50%      4
  66%      5
  75%      6
  80%      7
  90%      9
  95%     12
  98%     19
  99%     29
 100%   4175 (longest request)












[root@node2 myapp]# ab -n 10000 -c 10 http://172.18.21.30/
This is ApacheBench, Version 2.3 <$Revision: 1430300 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 172.18.21.30 (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests


Server Software:        nginx/1.10.0
Server Hostname:        172.18.21.30
Server Port:            80

Document Path:          /
Document Length:        84870 bytes

Concurrency Level:      10
Time taken for tests:   27.032 seconds
Complete requests:      10000
Failed requests:        1018
   (Connect: 0, Receive: 0, Length: 1018, Exceptions: 0)
Write errors:           0
Total transferred:      850318858 bytes
HTML transferred:       848698858 bytes
Requests per second:    369.93 [#/sec] (mean)
Time per request:       27.032 [ms] (mean)
Time per request:       2.703 [ms] (mean, across all concurrent requests)
Transfer rate:          30718.50 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    1   0.5      0       5
Processing:     7   26   7.2     25     198
Waiting:        3   23   6.3     22     185
Total:          7   27   7.2     26     198
ERROR: The median and mean for the initial connection time are more than twice the standard
       deviation apart. These results are NOT reliable.

Percentage of the requests served within a certain time (ms)
  50%     26
  66%     27
  75%     27
  80%     28
  90%     30
  95%     34
  98%     40
  99%     52
 100%    198 (longest request)
















[root@node2 myapp]# ab -n 10000 -c 10 http://172.18.21.30/
This is ApacheBench, Version 2.3 <$Revision: 1430300 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 172.18.21.30 (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests


Server Software:        nginx/1.10.0
Server Hostname:        172.18.21.30
Server Port:            80

Document Path:          /
Document Length:        84870 bytes

Concurrency Level:      10
Time taken for tests:   28.684 seconds
Complete requests:      10000
Failed requests:        967
   (Connect: 0, Receive: 0, Length: 967, Exceptions: 0)
Write errors:           0
Total transferred:      851998930 bytes
HTML transferred:       848698930 bytes
Requests per second:    348.62 [#/sec] (mean)
Time per request:       28.684 [ms] (mean)
Time per request:       2.868 [ms] (mean, across all concurrent requests)
Transfer rate:          29006.43 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    1   0.5      0       9
Processing:     6   28   4.6     27     118
Waiting:        4   25   3.8     24     114
Total:          7   29   4.6     28     120
WARNING: The median and mean for the initial connection time are not within a normal deviation
        These results are probably not that reliable.

Percentage of the requests served within a certain time (ms)
  50%     28
  66%     29
  75%     29
  80%     30
  90%     32
  95%     35
  98%     39
  99%     43
 100%    120 (longest request)































